﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mighty.Lib.Document
{
    public class DefaultDocumentRepository : IDocumentRepository
    {
        #region IDocumentRepository Members

        private IOpenProvider _openProvider = null;
        private ISaveProvider _saveProdiver = null;

        public DefaultDocumentRepository(IOpenProvider loadProvider, ISaveProvider saveProvider)
        {
            _openProvider = loadProvider;
            _saveProdiver = saveProvider;
        }

        public IDocument New()
        {
            return new DefaultDocument();
        }

        public IDocument Open(Dictionary<string, object> openParameters)
        {

            IDocument doc = new DefaultDocument(_openProvider, openParameters);
            doc.HasBeenSavedBefore = true;
            doc.FullPath = (string)openParameters["OpenFilePath"];
            return doc;
        }

        public void Save(Dictionary<string, object> saveParameters)
        {
            _saveProdiver.Save(saveParameters);
        }



        #endregion
    }
}
